extern _printf

SECTION .data
	a: dd 0
	b: dq 0.0
	igual: dd 0
	const1: dq 5.3

	intFormat: db "%d", 10, 0
	doubleFormat: db "%.2f", 10, 0

SECTION .text
	global _WinMain@16

	_fatorialNaoRecursivo:
		push ebp
		mov ebp, esp

		sub esp, 4
		push dword 1
		pop dword [ebp-4]

		push dword [ebp+8]
		push dword 0
		pop ebx
		pop eax
		cmp eax, ebx
		jle fatorialNaoRecursivo_else_1_block

		fatorialNaoRecursivo_while_1_begin:
		push dword 1
		push dword 1
		pop ebx
		pop eax
		cmp eax, ebx
		jne fatorialNaoRecursivo_while_1_end

		push dword [ebp-4]
		push dword [ebp+8]
		pop ebx
		pop eax
		imul eax, ebx
		push eax
		pop dword [ebp-4]

		push dword [ebp+8]
		push dword 1
		pop ebx
		pop eax
		sub eax, ebx
		push eax
		pop dword [ebp+8]

		push dword [ebp+8]
		push dword 0
		pop ebx
		pop eax
		cmp eax, ebx
		jne fatorialNaoRecursivo_endif_2

		jmp fatorialNaoRecursivo_while_1_end

		fatorialNaoRecursivo_endif_2:

		jmp fatorialNaoRecursivo_while_1_begin

		fatorialNaoRecursivo_while_1_end:

		push dword [ebp-4]
		pop eax
		mov esp, ebp
		pop ebp
		ret

		jmp fatorialNaoRecursivo_endif_1

		fatorialNaoRecursivo_else_1_block:
		push dword 0
		pop eax
		mov esp, ebp
		pop ebp
		ret

		fatorialNaoRecursivo_endif_1:

	_fatorialRecursivo:
		push ebp
		mov ebp, esp

		sub esp, 4
		push dword [ebp+8]
		push dword 0
		pop ebx
		pop eax
		cmp eax, ebx
		jle fatorialRecursivo_else_1_block

		push dword [ebp+8]
		push dword 1
		pop ebx
		pop eax
		cmp eax, ebx
		jne fatorialRecursivo_else_2_block

		push dword 1
		pop eax
		mov esp, ebp
		pop ebp
		ret

		jmp fatorialRecursivo_endif_2

		fatorialRecursivo_else_2_block:
		push dword [ebp+8]
		pop dword [ebp-4]

		push dword [ebp+8]
		push dword 1
		pop ebx
		pop eax
		sub eax, ebx
		push eax
		pop dword [ebp+8]

		push dword [ebp+8]
		call _fatorialRecursivo
		add esp, 4
		push eax
		pop dword [ebp+8]

		push dword [ebp-4]
		push dword [ebp+8]
		pop ebx
		pop eax
		imul eax, ebx
		push eax
		pop dword [ebp-4]

		push dword [ebp-4]
		pop eax
		mov esp, ebp
		pop ebp
		ret

		fatorialRecursivo_endif_2:

		jmp fatorialRecursivo_endif_1

		fatorialRecursivo_else_1_block:
		push dword 0
		pop eax
		mov esp, ebp
		pop ebp
		ret

		fatorialRecursivo_endif_1:

	_WinMain@16:
		push ebp
		mov ebp, esp

		sub esp, 16
		fld qword [const1]

		fstp qword [ebp-16]

		fld qword [ebp-16]
		fstp qword [b]

		fld qword [b]
		fld qword [ebp-16]
		faddp st1
		fstp qword [b]

		push dword 5
		pop dword [a]

		push dword [a]
		call _fatorialNaoRecursivo
		add esp, 4
		push eax
		pop dword [ebp-8]

		push dword [a]
		call _fatorialRecursivo
		add esp, 4
		push eax
		pop dword [ebp-4]

		push dword 0
		pop dword [igual]

		push dword [ebp-8]
		push dword [ebp-4]
		pop ebx
		pop eax
		cmp eax, ebx
		jne WinMain@16_endif_1

		push dword 1
		pop dword [igual]

		WinMain@16_endif_1:

		push dword [a]
		push dword intFormat
		call _printf
		add esp, 8

		push dword [ebp-8]
		push dword intFormat
		call _printf
		add esp, 8

		push dword [ebp-4]
		push dword intFormat
		call _printf
		add esp, 8

		push dword [igual]
		push dword intFormat
		call _printf
		add esp, 8

		push dword [b+4]
		push dword [b]
		push dword doubleFormat
		call _printf
		add esp, 12

		mov esp, ebp
		pop ebp
		mov eax, 0
		ret
